﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
using RFC.AOP;

namespace RFC.Emit.Demo.ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            //BuilderClassType builderClassType = new BuilderClassType("Test", "Test");
            //var typeBuilder = builderClassType.DefineType("Test");
            //var methodBuilder = builderClassType.DefineMethod(ref typeBuilder, "Say");
            //var il = builderClassType.GetILGenerator(methodBuilder);
            //builderClassType.LoadString(ref il, "你好");
            //builderClassType.Call(ref il, typeof(Console), "WriteLine", typeof(string));
            //builderClassType.Return(ref il);
            //var type = builderClassType.Save(typeBuilder);
            //var test = Activator.CreateInstance(type) as dynamic;
            //test.Say();

            //var newType = AOP.ApectProxyBuilder.Create<ITest,Test>();
            //newType.GetMethod("Say").Invoke(newType, new object[] {"你好"});
            //var method = (dynamic) Activator.CreateInstance(newType);
            //method.Say("你好");
            //ITest newTest = (ITest) Activator.CreateInstance(newType);
            //newTest.Say("你好");
            //var test = ApectProxyBuilder.CreateInstance<ITest,Test>("构造函数参数");
            //test.Say("说点什么");
            //test.Add(2, 4);

            var testType = ApectProxyBuilder.BuildType<ITest, Test>();
            ITest test = (ITest)Activator.CreateInstance(testType, "构造函数参数");
            //test.Say("说点什么");
            //test.Add(2, 4);

            Console.ReadKey();
        }
    }
}
